package com.java110.mall.cart.smo.impl;


import com.java110.mall.cart.dao.IHousekeepingServUserServiceDao;
import com.java110.dto.housekeeping.HousekeepingServUserDto;
import com.java110.intf.cart.IHousekeepingServUserInnerServiceSMO;
import com.java110.po.housekeeping.HousekeepingServUserPo;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.core.base.smo.BaseServiceSMO;
import com.java110.dto.PageDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName FloorInnerServiceSMOImpl
 * @Description 维修师傅内部服务实现类
 * @Author wuxw
 * @Date 2019/4/24 9:20
 * @Version 1.0
 * add by wuxw 2019/4/24
 **/
@RestController
public class HousekeepingServUserInnerServiceSMOImpl extends BaseServiceSMO implements IHousekeepingServUserInnerServiceSMO {

    @Autowired
    private IHousekeepingServUserServiceDao housekeepingServUserServiceDaoImpl;


    @Override
    public int saveHousekeepingServUser(@RequestBody HousekeepingServUserPo housekeepingServUserPo) {
        int saveFlag = 1;
        housekeepingServUserServiceDaoImpl.saveHousekeepingServUserInfo(BeanConvertUtil.beanCovertMap(housekeepingServUserPo));
        return saveFlag;
    }

     @Override
    public int updateHousekeepingServUser(@RequestBody  HousekeepingServUserPo housekeepingServUserPo) {
        int saveFlag = 1;
         housekeepingServUserServiceDaoImpl.updateHousekeepingServUserInfo(BeanConvertUtil.beanCovertMap(housekeepingServUserPo));
        return saveFlag;
    }

     @Override
    public int deleteHousekeepingServUser(@RequestBody  HousekeepingServUserPo housekeepingServUserPo) {
        int saveFlag = 1;
        housekeepingServUserPo.setStatusCd("1");
        housekeepingServUserServiceDaoImpl.updateHousekeepingServUserInfo(BeanConvertUtil.beanCovertMap(housekeepingServUserPo));
        return saveFlag;
    }

    @Override
    public List<HousekeepingServUserDto> queryHousekeepingServUsers(@RequestBody  HousekeepingServUserDto housekeepingServUserDto) {

        //校验是否传了 分页信息

        int page = housekeepingServUserDto.getPage();

        if (page != PageDto.DEFAULT_PAGE) {
            housekeepingServUserDto.setPage((page - 1) * housekeepingServUserDto.getRow());
        }

        List<HousekeepingServUserDto> housekeepingServUsers = BeanConvertUtil.covertBeanList(housekeepingServUserServiceDaoImpl.getHousekeepingServUserInfo(BeanConvertUtil.beanCovertMap(housekeepingServUserDto)), HousekeepingServUserDto.class);

        return housekeepingServUsers;
    }


    @Override
    public int queryHousekeepingServUsersCount(@RequestBody HousekeepingServUserDto housekeepingServUserDto) {
        return housekeepingServUserServiceDaoImpl.queryHousekeepingServUsersCount(BeanConvertUtil.beanCovertMap(housekeepingServUserDto));    }

    public IHousekeepingServUserServiceDao getHousekeepingServUserServiceDaoImpl() {
        return housekeepingServUserServiceDaoImpl;
    }

    public void setHousekeepingServUserServiceDaoImpl(IHousekeepingServUserServiceDao housekeepingServUserServiceDaoImpl) {
        this.housekeepingServUserServiceDaoImpl = housekeepingServUserServiceDaoImpl;
    }
}
